<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <ul>
      <!-- key的作用，提高性能（虚拟dom运算的时候） -->
      <li v-for="(city,idx) in cities" :key="idx">
        {{idx}}: {{city.name}}-{{city.num}}
      </li>
    </ul>
    <hr>

    <div v-for="(value,key,index) in user">
      {{index}}- {{value}}-{{key}}
    </div>

    <hr>
    <ul>
      <li v-for="i in getEvenNum()">
        {{i}}
      </li>
    </ul>
    <hr>
    <span v-for="n in 10">{{ n }} </span>

    <hr>

    <template v-for="n in 10" >
      <h1>h1</h1>
      <h2>h2</h2>
    </template>

  </div>
  <script>

    var vm = new Vue({
      el: "#app",
      data: {
        datalist: [1, 2, 3, 4, 5, 6],
        cities: [{ name: "太原", num: 800 }, { name: "北京", num: 3000 }],
        user: {
          name: "weitao",
          age: 18,
          address: '太原'
        }
      },
      computed: {
        evenNum() {
          return this.datalist.filter((item) => { return item % 2 === 0 })
        }
      },
      methods: {
        getEvenNum() {
          return this.datalist.filter((item) => { return item % 2 === 0 })
        }
      }
    })

    // vm.datalist= vm.datalist.filter((item)=>{ return item%2===0 })
  </script>

</body>

</html>